package me.zk.practice1.hw;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

/**
 * @author zhangkai
 * @date 2023/8/7 16:35
 */
public class HWBJ71 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        List<int[]> list = new ArrayList<>();
        while (scanner.hasNext()) {
            String[] nums = scanner.nextLine().split(" ");
            int h = Integer.parseInt(nums[0]);
            if (h == -1) {
                break;
            }
            int w = Integer.parseInt(nums[1]);
            list.add(new int[]{h,w});
        }
        list.sort(new Comparator<int[]>() {
            @Override
            public int compare(int[] o1, int[] o2) {
                if (o1[0] > o2[0]) {
                    return -1;
                } else if (o1[0] == o2[0]) {
                    return o2[1]-o1[1];
                } else {
                    return 1;
                }
            }
        });
        int len = Math.min(list.size(), 10);
        for (int i = 0; i < len; i++) {
            int[] n = list.get(i);
            System.out.println(n[0]+ " " + n[1]);
        }
    }
}
